package com.lcm.weam.service.sys.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.lcm.weam.dao.sys.PermissionMapper;
import com.lcm.weam.entity.sys.Permission;
import com.lcm.weam.service.sys.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PermissionServiceImpl implements PermissionService {

    @Autowired
    private PermissionMapper permissionMapper;

    public void addPermission(Permission permission) {
        permissionMapper.insert(permission);
    }

    public void updatePermission(Permission permission, Integer pid) {
        permissionMapper.update(permission, new UpdateWrapper<Permission>().eq("pid", pid));
    }

    public List<Permission> selectAllPermission() {
        return permissionMapper.selectList(null);
    }

    public void deletePermission(Integer pid) {
        permissionMapper.deleteMapById(pid);
        permissionMapper.delete(new QueryWrapper<Permission>().eq("pid",pid));
    }
    
}
